from django.db import models
from Eventati.settings import MEDIA_ROOT

# Create your models here.
class User(models.Model):
    first_name = models.CharField(max_length = 30)
    last_name = models.CharField(max_length = 30)
    email =models.EmailField()
    password = models.CharField(max_length=10)
    confirmpassword = models.CharField(max_length=10)
    phone = models.CharField(max_length = 30)
    Active = models.BooleanField()
    SystemModerator = models.BooleanField()
    def __unicode__(self):
        return self.first_name
 
class LiveStream(models.Model):
    channel = models.CharField(max_length = 50)
    def __unicode__(self):
        return self.channel
    
class Agenda(models.Model):
    title =  models.CharField(max_length = 20 )
     
class Activity(models.Model):
    description = models.CharField(max_length=300)
    startTime = models.TimeField()
    endTime = models.TimeField()
    agendaID = models.ForeignKey(Agenda)

class SocialMarketing (models.Model):
    twitterUserName = models.CharField(max_length = 70)
    facebookUrl = models.URLField()
    hashTag = models.CharField(max_length = 70)    
    
class Component(models.Model):
    title=models.CharField(max_length=30)
    description=models.TextField()
    approved=models.BooleanField()
    rejected=models.BooleanField()
    
    def viewComp(self):
        """
        Author: Heba El Mohandes C1-10
        This method makes a link in the admin page by clicking on it redirects me to ViewComponent.html in order to view suggested component by the user.
        Args:
            Self 
        Returns:
            Returns page that contains the suggested component to be viewed by the admin 
        How to use the funtion:
            Type the localhost "http://localhost:8000/ViewComponent/1/"
        """
        return '<a href="../../../ViewComponent/%s/">View</a>' % (self.id)
    viewComp.allow_tags = True
   
            

class Faq (models.Model):
    question = models.TextField()
    answer = models.TextField()
    def __unicode__(self):
        return self.question


class TermsAndCondition (models.Model):
    title = models.CharField(max_length=500)
    description = models.TextField()
    def __unicode__(self):
        return self.title
        
class NewsAndUpdate (models.Model):
    title = models.CharField(max_length=500)
    description = models.TextField()
    def __unicode__(self):
        return self.title
		
		
class KnowledgeStore(models.Model):
    title= models.CharField(max_length=100)
    description= models.TextField()
    videoTitle=models.CharField(max_length=100)
    link= models.URLField(max_length = 200)
    
    def __unicode__(self):
        return self.title
    
class EventTemplate (models.Model):
    name= models.CharField(max_length=255)
    def __unicode__(self):
        return self.name
	
    
class Location(models.Model):
    name=models.CharField(max_length=255)
    def __unicode__(self):
        return self.name


class Media(models.Model):
    photo = models.ImageField(upload_to='uploadPhoto')
    
	
class Payment(models.Model):
    paymentAmount = models.CharField(max_length = 50)
    deadline = models.CharField(max_length = 50)

class CreatorTemplate(models.Model):
    name= models.CharField(max_length=255)
    startDate= models.DateField(default="2012-05-28")
    endDate= models.DateField(default="2012-05-28")
    startTime= models.TimeField(default= "00:00")
    endTime= models.TimeField(default= "01:00")
    eventName=models.TextField(max_length=255, default= "not decided")
    payment=models.ForeignKey(Payment) 
    media=models.ForeignKey(Media)
    location=models.ForeignKey(Location)
    agenda=models.ForeignKey(Agenda)
    liveStream= models.ForeignKey(LiveStream)
    socialMarketing= models.ForeignKey(SocialMarketing)
    brideName = models.CharField(max_length=70, default=" ")
    groomName = models.CharField(max_length=70, default="   ")
    birthdayOwner = models.CharField(max_length=70, default= "   ")
    singerName = models.CharField(max_length=70, default="   ")
    charityType = models.CharField(max_length=70, default="   ")
    description = models.CharField(max_length=500, default=" ")
    
    def __unicode__(self):
        return self.name

class NewChoices (models.Model):
    template = models.ForeignKey(CreatorTemplate)
    name= models.CharField(max_length=70)
    def __unicode__(self):
        return self.name

class Event(models.Model):
    template = models.ForeignKey(CreatorTemplate) 
    isPublic = models.BooleanField()
    isApproved = models.BooleanField()
    isRejected = models.BooleanField()
    creator = models.ForeignKey(User)
    visibility = models.BooleanField()
    countShare=models.IntegerField()    
    date = models.DateField(default="2013-01-1")
    
    
    
class Locations(models.Model):
    BlockNumber=models.CharField(max_length=255)    
    Street=models.CharField(max_length=255)
    city=models.CharField(max_length=255)
    Country=models.CharField(max_length=255)
    event = models.ForeignKey(Event)
class Category (models.Model):
    categoryTitle = models.CharField(max_length = 255)
    
class Page (models.Model):
    title = models.CharField(max_length = 255)
    description = models.TextField()
    category = models.ForeignKey(Category)
    event = models.ForeignKey(Event)
    def __unicode__ (self):
        return self.title
class Menu  (models.Model):
    title = models.CharField(max_length=30)
    event = models.ForeignKey(Event)
    def __unicode__(self):
        return self.title
    
class Link (models.Model):
    url = models.URLField()
    name = models.CharField(max_length=50)
    menu = models.ForeignKey(Menu)
    event = models.ForeignKey(Event)
    
    
class LikeEvent(models.Model):
    user=models.ForeignKey(User)
    event=models.ForeignKey(Event)
    date = models.DateField(auto_now_add=True)		
    
class PageViewers(models.Model):
    user = models.ForeignKey(User)
    event = models.ForeignKey(Event)

class PageCounter(models.Model):
    event = models.ForeignKey(Event)
    pageCounter = models.IntegerField()

class List (models.Model):
    title = models.CharField(max_length = 100)
    event = models.ForeignKey(Event)
    createdByUser = models.CharField(max_length=10)    
class SelectedComponents (models.Model):
    template = models.ForeignKey(CreatorTemplate)
    name= models.CharField(max_length=70)
    def __unicode__(self):
        return self.name
     
class Attending(models.Model):
    user = models.ForeignKey(User) 
    event = models.ForeignKey(Event)
    
class MaybeAttending(models.Model):
    user = models.ForeignKey(User)
    event = models.ForeignKey(Event)
    
class NotAttending(models.Model):
    user = models.ForeignKey(User)
    event = models.ForeignKey(Event)
    
class Visitor(models.Model):
    user = models.ForeignKey(User)
    event = models.ForeignKey(Event)
    
class Invited(models.Model):
    user = models.ForeignKey(User)
    event = models.ForeignKey(Event)

class PayedAttendees (models.Model):
    user = models.ForeignKey(User)
    event = models.ForeignKey(Event)

class Item (models.Model):
    title = models.CharField(max_length = 250)   
    completed = models.BooleanField()
    todoList = models.ForeignKey(List)
    assignedTo = models.CharField(max_length = 50)



class EventModerator(models.Model):
    user=models.ForeignKey(User)
    event=models.ForeignKey(Event)
	
class Contact(models.Model):
    message=models.TextField()
    email=models.EmailField()
    def __unicode__(self):
        return self.title
		
class Photo(models.Model):    
    fileImage  = models.ImageField(upload_to = "photos" , null = True, blank = True)
    event = models.ForeignKey(Event)
    
class Video(models.Model):
    title = models.CharField(max_length = 30)
    video  = models.FileField(upload_to = "videos" , null = True, blank = True)
    event = models.ForeignKey(Event)
	    
class Bookmark(models.Model):
   user = models.ForeignKey(User)
   event = models.ForeignKey(Event)